<!doctype html>
<html lang="en">
<head>
    @include('web.layout.head')
    <link rel="stylesheet" href="{{mix('/css/web/user/prove_release.css')}}">
    <script src="{{mix('/js/web/frame/jedate/jquery.jedate.js')}}"></script>
    <link rel="stylesheet" href="{{mix('/js/web/frame/jedate/skin/jedate.css')}}">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

</head>
<body>

@include('web.layout.header')
@include('web.layout.user_tab')
<div class="base_member_content">
    <div class="w1200">
      @include('web.layout.seller_nav')
      <div class="right fr">
        <div class="marryreal">
          <div class="name">
            <span class="goodsfabu">商品管理</span>
            <a href="/seller/prove_release_first"><div class=" fabulink">发布商品</div></a>
          </div>
          <div class="marryst">
            <form action="{{URL::current()}}" method="get">
            <span>关键字</span>
            <input type="text" name="product_name" class="ssearch" id="guanjianfont" placeholder="商品名字" value="{{ request('product_name') }}">
            <span style="margin-left: 18px;">商品ID</span>
            <input type="text"  class="ssearch" name="sku_code" placeholder="商品ID" value="{{request('sku_code')}}">
            <span style="margin-left: 18px;">时间</span>
            <input name="date_beg" class="datainp" id="inpstart" type="text" placeholder="开始日期" readonly="" value="{{request('date_beg')}}">
            <input name="date_end" class="datainp" id="inpend" type="text" placeholder="结束日期" readonly="" value="{{request('date_end')}}">
            <span style="margin-left: 18px;">状态</span>
            <select name="status">
              <option value="">请选择</option>
              <option value="onsale" @if(request('status','') == 'onsale') selected @endif>已上架</option>
              <option value="offsale"  @if(request('status','') == 'offsale') selected @endif>已下架</option>
              <option value="drafts"  @if(request('status','') == 'drafts') selected @endif>草稿箱</option>
            </select>
            <input type="submit" class="buttonn" value="查询">
            </form>
          </div>
          <div style="display:none">
          <input type="hidden" name="_scfs" value="ca350fa4d74c3b6d1640990f75488f06"/>
          </div>
          <div class="conttent">
            <div>
            <lable><input type="checkbox" name="" id="allxz">全选</lable>
            <input type="submit" class="shelves do-curd" data-action="do-onsale" value="上架">
            <input type="submit" class="shelves do-curd" data-action="do-offsale" value="下架">
            <input type="submit" class="shelves do-curd" data-action="do-delete" value="删除">
            <span class="total">共<span class="blue">1111</span>条</span>
            </div>
          </div>
          <div class="table list">
              <table>
                  <thead>
                  <tr>
                      <th width="40"></th>
                      <th width="120">图片</th>
                      <th>标题</th>
                      <th width="120">价格(元)</th>
                      <th width="90">状态</th>
                      <th width="170">修改时间</th>
                      <th>操作</th>
                  </tr>
                  </thead>
                  <tbody>
                  <tr>
                      <td><input type="checkbox" name="id[]" value="1"></td>
                      <td>
                        <a target="_blank" href="/shop/detail/1">
                          <img width="70" height="70" src="111">
                        </a>
                      </td>
                      <td>
                        <span class="goodsname">
                          <a target="_blank" href="/shop/detail/1"> 商品 </a>
                        </span>
                        <span class="goodsid">商品ID：1</span>
                      </td>
                      <td class="goodsprice">
                          <span>¥11.00</span>
                          <font>¥11.00</font>
                      </td>
                      <td>已上架</td>
                      <td>2017/08/02 13:48:49</td>
                      <td><a href="{{asset('/seller/edit_prove_release/1')}}">编辑</a></td>
                  </tr>
                  <tr>
                      <td><input type="checkbox" name="id[]" value="1"></td>
                      <td>
                        <a target="_blank" href="/shop/detail/1">
                          <img width="70" height="70" src="111">
                        </a>
                      </td>
                      <td>
                        <span class="goodsname">
                          <a target="_blank" href="/shop/detail/1"> 商品 </a>
                        </span>
                        <span class="goodsid">商品ID：1</span>
                      </td>
                      <td class="goodsprice">
                          <span>¥11.00</span>
                          <font>¥11.00</font>
                      </td>
                      <td>已下架</td>
                      <td>2017/08/02 13:48:49</td>
                      <td><a href="{{asset('/seller/edit_prove_release/1')}}">编辑</a></td>
                  </tr>
                  </tbody>
              </table>
          </div>
          <div class="marryreal">
              include("web.layout.page")
          </div>
        </div>
      </div>
    </div>

</div>
@include('web.layout.footer')
<script type="text/javascript">
  var start = {
      format: 'YYYY-MM-DD hh:mm',
      minDate: '2014-06-16 23:59:59', //设定最小日期为当前日期
      //festival:true,
      maxDate: $.nowDate({DD:0}), //最大日期
      choosefun: function(elem,datas){
          end.minDate = datas; //开始日选好后，重置结束日的最小日期
          endDates();
      },
      okfun:function (elem,datas) {
          alert(datas)
      }
  };
  var end = {
      format: 'YYYY-MM-DD hh:mm',
      minDate: $.nowDate({DD:0}), //设定最小日期为当前日期
      //festival:true,
      maxDate: '2099-06-16 23:59:59', //最大日期
      choosefun: function(elem,datas){
          start.maxDate = datas; //将结束日的初始值设定为开始日的最大日期
      }
  };
  function endDates() {
      end.trigger = false;
      $("#inpend").jeDate(end);
  }
  $("#inpstart").jeDate(start);
  $("#inpend").jeDate(end);

  $(function(){
      //日期选择获取的值
      $(".buttonn").click(function(){
          console.log($("#guanjianfont").val());
          console.log($("#goodsid").val());
          console.log($("#inpstart").val());
          console.log($("#inpend").val());
          console.log($(".marryst select").val());
      })

      $("#allxz").click(function(){
          //全选 反选
      if (this.checked==true) {
       $(".marryreal .list  input:checkbox").prop("checked", true);
          }else{
              $(".marryreal .list  input:checkbox").prop("checked", false);
          }
       })

      $(".table tr").mouseover(function (){
          $(this).css('background','#f5f5f5');
      }).mouseout(function (){
          $(this).css('background','#fff');
      });
  })


  function doAction(params,url){
      $.ajax({
          url: url,
          type: 'post',
          dataType: 'json',
          data: params,
          success:function (data) {
              if (data.code == 0) {
                layer.alert('已提交成功',{
                    icon: 1
                },function () {
                    location.reload();
                });
              }else{
                  layer.alert('操作失败',{icon: 1});
              }
          }
      })
  }
  //上架
  $('.do-curd').click(function(){
      var ids = [];
      var url = '',param = {_token:'{{csrf_token()}}'};
      $(".marryreal .list  input:checked").each(function(i,n){
         ids.push(parseInt($(n).val()))
      });
      if(ids.length == 0){
          layer.alert('请先勾选商品',{icon: 0});
          return false;
      }
      param.lib_product_ids = ids;
      switch($(this).data('action')){
          case 'do-delete':
              url = '/seller/delete';
              break;
          case 'do-onsale':
              url = '/seller/set-on-sale';
              param.is_forsale = 1;
              break;
          case 'do-offsale':
              url = '/seller/set-on-sale';
              param.is_forsale = 0;
              break;
      }
      doAction(param,url);
  });
</script>
</body>
</html>